package dangs.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import dangs.vo.LocationVO;
import dangs.vo.ProductVO;

public class ProductDAO {
	private SqlMapClientTemplate client;
	public ProductDAO(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public void registerProduct(ProductVO pvo) throws SQLException{
		client.insert("registerProduct", pvo);
	}
	
	public void updateProduct(ProductVO pvo) throws SQLException{
		client.update("updateProduct", pvo);
	}
	
	public ProductVO selectByProductId(String productCode) throws SQLException{
		ProductVO pvo = (ProductVO)client.queryForObject("selectByProductId", productCode);
		return pvo;
	}

	public ArrayList productList() throws SQLException{
		ArrayList list = (ArrayList)client.queryForList("selectAllProduct");
		return list;
	}
	public void deleteByProductId(ProductVO pvo) throws SQLException{
		String productCode = pvo.getProductCode();
		client.delete("deleteByProductId", productCode);
	}
	public ArrayList selectProductforNow(String date) throws SQLException{
		ArrayList list = (ArrayList)client.queryForList("selectProductForNow", date);
		return list;
	}
	
}
